 <?php
	$public_application = $this->config->item('public_application');
 ?>
<script src="<?php echo base_url($public_application."js/jquery.validate.min.js")?>"></script>
<div class="main-bg clearfix">
  <div class="container main-box clearfix">
  <?php if(validation_errors()){error(validation_errors()); } if($error){error($error);}?>
    <div class="row">
	
        <div class="col-md-6 col-md-offset-3">
            <p class="text-center mt-2em">
			
		           <p class="text-center">
		            <a href="<?php echo site_url('account');?>" class="btn btn-danger btn-lg"> 基本资料 </a>&nbsp;&nbsp;&nbsp;&nbsp;	    
		            <a href="<?php echo site_url('ecard/ecardList');?>" class="btn btn-danger btn-lg   cur-active">我品牌书</a>
		          </p>
		    </p>
		   
			  <?php 
			  $attributes = array(
				'class' => "form-horizontal",
				'id' => "profile_form"
			  ); 
			  echo form_open('account/profile',$attributes);
			  ?>
			   <div class="form-group">
				
			  </div>
		          <input type="hidden" name="action" value="update"/>
		          <div class="text-center">
				  <?php if($userinfo):?>
		            <a href="<?php echo site_url('account/avatar')?>"><img src="<?php echo UC_API;?>/avatar.php?uid=<?php echo $userinfo['id']?>&type=virtual&size=big" /></a>
		            <p><?php echo $userinfo['username']?>(点击图像可编辑)</p>
				  <?php endif;?>
		          </div>

		  <?php if($userinfo):?>
		  <?php $dropdown = $this->config->item('dropdown');?>
		  <div class="form-group">
		    <label  class="col-sm-2 control-label">性别</label>
		    <div class="col-md-3 col-sm-3">
			<?php echo form_dropdown('sex',$dropdown['sex'],$userinfo['sex'],'class="form-control input-lg"');?>
		    </div>
		  </div>
		  <div class="form-group">
		    <label  class="col-sm-2 control-label">生日</label>
		    <div class="col-md-5 col-sm-5">
		      <input type="text" class="form-control input-lg" name="birthday" value="<?php echo $userinfo['birthday']?>">
		    </div>
		  </div>
		  <div class="form-group">
		    <label  class="col-sm-2 control-label">星座</label>
		    <div class="col-md-3 col-sm-3">
			<?php echo form_dropdown('constellation',$dropdown['constellation'],$userinfo['constellation'],'class="form-control input-lg"');?>
		     
		    </div>
		  </div>
		  <div class="form-group">
		    <label  class="col-sm-2 control-label">邮箱</label>
		    <div class="col-md-5 col-sm-5">
		      <input type="email" class="form-control input-lg" name="email" value="<?php echo $userinfo['email']?>">
		    </div>
		  </div>
		  <div class="form-group">
		    <label  class="col-sm-2 control-label">地区</label>
		    <div class="col-md-8 col-sm-8">
		      <textarea type="text" class="form-control input-lg" name="address"><?php echo $userinfo['address']?></textarea>
		    </div>
		  </div>
		  <div class="form-group">
		    <label  class="col-sm-2 control-label">新密码</label>
		    <div class="col-md-5 col-sm-5">
		      <input type="password"  class="form-control input-lg" name="password"  id="password" placeholder="留空则不更改" autocomplete="off">
		    </div>
		  </div>
		  <div class="form-group">
		    <label  class="col-sm-2 control-label">确认密码</label>
		    <div class="col-md-5 col-sm-5">
		      <input type="password" class="form-control input-lg" name="repassword" id="repassword" placeholder="需要和新密码相同" autocomplete="off">
		    </div>
		  </div>
		  <div class="form-group">
		    <div class="col-sm-offset-2 col-sm-10">
		      <button type="submit" class="btn btn-primary">&nbsp;&nbsp;保 存&nbsp;&nbsp;</button>
		      <button type="reset" class="btn btn-danger">&nbsp;&nbsp;取 消&nbsp;&nbsp;</button>
		    </div>
		  </div>
		  <?php endif;?>
		  <?php echo form_close();?>
		</div>
		
		</div>
	</div>
  </div>
  <script>
 $(document).ready(function(){
	 $('#profile_form').validate({
		 rules:{
			 email: {email:true},
		     username: "required",
			 repassword:{equalTo:'#password'}
		 },
		 messages:{
			 email:{email:"您填写的邮箱格式有误"},
		     repassword:{equalTo:"两次密码输入不一致"}
		 },
		 errorPlacement: function(error, element) {
			    error_box = $('<div class="col-md-5 col-sm-5 "> </div>');
			    error_box.append(error);
			    
			      error_box.appendTo(element.parent().parent());  
		 }
	 });

 });
</script>